package school.valon.constantes;

import school.valon.dto.UserTypeDto;

public enum EnumUserType {
	ADMIN(1, "admin"), STAFF(2, "staff"), STUDENT(3, "student"),
	PARENT(4, "parent"), OUTSIDE_DONATOR(5, "outside donator");

	private int typeId;
	private String caption;
	private EnumUserType(int typeId, String caption) {
		this.typeId = typeId;
		this.caption = caption;
	}

	public int getTypeId() {
		return this.typeId;
	}
	public String getCaption() {
		return this.caption;
	}

	public static EnumUserType getUserTypeById(int typeId) {
		for(EnumUserType enumTypeIt : EnumUserType.values()) {
			if (enumTypeIt.typeId == typeId) {
				return enumTypeIt;
			}
		}
		return null;
	}

	public UserTypeDto getUserTypeDto() {
		UserTypeDto userTypeDto = new UserTypeDto();
		userTypeDto.setUserTypeId(this.typeId);
		return userTypeDto;
	}
}
